package org.backend.repository;

import org.backend.pojo.entity.Favor;
import org.backend.pojo.dto.ProductSummaryDTO;
import org.backend.pojo.entity.Product;
import org.backend.mapper.ProductMapper;
import org.backend.pojo.vo.ProductCategoriesVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductRepository {
    @Autowired
    private ProductMapper productMapper;

    public List<Product> findAll2Web(String userId) {
        return productMapper.findAll2Web(userId);
    }

    public List<Product> findAll(String userId, String openid) {
        return productMapper.findAll(userId, openid);
    }

    public List<ProductSummaryDTO> findProdStats(String userId) {
        return productMapper.findProdStats(userId);
    }

    public int publish(Product product) {
        return productMapper.publish(product);
    }

    public int delete(Integer productId) {
        return productMapper.delete(productId);
    }

    public int revise(Product product) {
        return productMapper.revise(product);
    }

    public List<Product> getAllProList() {
        return productMapper.getAllProList();
    }

    public List<Product> getPopularProducts() {
        return  productMapper.getPopularProducts();
    }

    public Product getProductById(Integer productId) {
        return productMapper.getProductById(productId);
    }

    public List<ProductCategoriesVO> getProductCategories() {
        return productMapper.getProductCategories();
    }

    public Favor getFavor(Favor favor) {
        return productMapper.getFavor(favor);
    }

    public int addFavor(Favor favor) {
        return productMapper.addFavor(favor);
    }

    public int removeFavor(Favor favor) {
        return productMapper.removeFavor(favor);
    }

    public List<Favor> getAllFavor(Favor favor) {
        return productMapper.getAllFavor(favor);
    }

    public void update(Product product) {
        productMapper.update(product);
    }
}
